#!/bin/sh
#
# Run example
#  

cygwin=false
linux=false
darwin=false

case "`uname`" in
CYGWIN*) cygwin=true;;
Linux*) linux=true;;
Darwin*) darwin=true;;
esac

if $linux; then
  SEPAR=':'
fi

if $darwin; then
  SEPAR=':'
fi

if $cygwin; then
  SEPAR=';'
fi

DEBUGOPTS='-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n'

JVMOPTS='-Djline.terminal=jline.UnixTerminal' 
JVMOPTS="$JVMOPTS"' -enableassertions'
JVMOPTS="$JVMOPTS"' -Dfractal.provider=fr.jade.fraclite.FracLite'
JVMOPTS="$JVMOPTS"' -Dfraclite.config=ReflexFracLite.xml'

for i in `ls dist/lib/`
do
  if [ "$CLASSPATH" = "" ]; then
    CLASSPATH=dist/lib/"$i"
  else
    CLASSPATH="$CLASSPATH""$SEPAR"dist/lib/"$i"
  fi
done

if [ "$1" != "" ]; then
  for i in `ls examples/$1/dist/lib/`
  do
    CLASSPATH="$CLASSPATH""$SEPAR"examples/$1/dist/lib/"$i"
  done
  CLASSPATH="$CLASSPATH""$SEPAR"examples/$1/etc
fi

echo $CLASSPATH

JAVA=java
MAIN=fr.jade.console.core.Launcher
ARGS='boot fr.jade.Jade'

stty -icanon min 1 -echo
$JAVA $JVMOPTS -classpath $CLASSPATH $MAIN "$ARGS"
stty icanon echo
